<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>6.270 - JoyOS: lib/geartrain.h File Reference</title>
	<link href="main.css" media="screen" rel="Stylesheet" type="text/css"/>
	<link href="doxygen.css" rel="stylesheet" type="text/css">
</head>  
<body>
	<div id="header">
		<div id="headerb">
		<div id="headtext">
			<span class="titletext">AUTONOMOUS ROBOT DESIGN COMPETITION</span>
			6.270
		</div>
		<div class="mainmenu">
			<a href="http://web.mit.edu/6.270/www">Home</a>
		 	&bull;
			<a href="http://web.mit.edu/6.270/www/about/">About</a> 
		 	&bull;
			<a href="http://web.mit.edu/6.270/www/sponsors/">Sponsors</a>
		 	&bull;
			<a href="http://web.mit.edu/6.270/www/contests/">Past Contests</a> 
		 	&bull;
			<a href="http://web.mit.edu/6.270/www/contestants/">Contestant Information</a>
		</div>
	</div>
	</div>

<div class="maincontent">
<!-- Generated by Doxygen 1.5.6 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
</div>
<div class="contents">
<h1>lib/geartrain.h File Reference</h1>Geartrain calculations and conversions. <a href="#_details">More...</a>
<p>
<code>#include &lt;math.h&gt;</code><br>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Defines</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="f66660c90796de7928494353583b7fd3"></a><!-- doxytag: member="geartrain.h::CM_TO_TICKS" ref="f66660c90796de7928494353583b7fd3" args="(cm)" -->
#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="geartrain_8h.html#f66660c90796de7928494353583b7fd3">CM_TO_TICKS</a>(cm)&nbsp;&nbsp;&nbsp;(uint32_t)((cm)*TICKS_PER_CM)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Convert from centimeters to encoder ticks. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="b2cb84acd610f05846fc9f969f591cac"></a><!-- doxytag: member="geartrain.h::DEG_TO_CM_IN_PLACE" ref="b2cb84acd610f05846fc9f969f591cac" args="(deg)" -->
#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="geartrain_8h.html#b2cb84acd610f05846fc9f969f591cac">DEG_TO_CM_IN_PLACE</a>(deg)&nbsp;&nbsp;&nbsp;((M_PI*WHEEL_TRACK)*(deg)/360.0)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Convert from degrees to cm of wheel rotation [rotation in place]. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="d6a3583d1656c3741bdb5c4f69c434f0"></a><!-- doxytag: member="geartrain.h::DEG_TO_TICKS_IN_PLACE" ref="d6a3583d1656c3741bdb5c4f69c434f0" args="(deg)" -->
#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="geartrain_8h.html#d6a3583d1656c3741bdb5c4f69c434f0">DEG_TO_TICKS_IN_PLACE</a>(deg)&nbsp;&nbsp;&nbsp;(CM_TO_TICKS(DEG_TO_CM_IN_PLACE(deg)))</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Convert from degrees to encoder ticks [rotation in place]. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="043725fc88584514d3feb59caf415e3d"></a><!-- doxytag: member="geartrain.h::DEG_TO_CM_CORNER" ref="043725fc88584514d3feb59caf415e3d" args="(deg)" -->
#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="geartrain_8h.html#043725fc88584514d3feb59caf415e3d">DEG_TO_CM_CORNER</a>(deg)&nbsp;&nbsp;&nbsp;((M_PI*2.0*WHEEL_TRACK)*(deg)/360.0)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Convert from degrees to cm of wheel rotation [rotation around one wheel]. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="332db33c43b7d400db11219975ba9bbf"></a><!-- doxytag: member="geartrain.h::DEG_TO_TICKS_CORNER" ref="332db33c43b7d400db11219975ba9bbf" args="(deg)" -->
#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="geartrain_8h.html#332db33c43b7d400db11219975ba9bbf">DEG_TO_TICKS_CORNER</a>(deg)&nbsp;&nbsp;&nbsp;(CM_TO_TICKS(DEG_TO_CM_CORNER(deg)))</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Convert from degrees to encoder ticks [rotation around one wheel]. <br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
This file defines a number of useful geartrain/distance/rotaion calculation and conversion routines.<p>
To use these functions the user must define the following values before including <a class="el" href="geartrain_8h.html" title="Geartrain calculations and conversions.">geartrain.h</a><p>
<ul>
<li>ENCODER_TO_WHEEL_RATIO - the ratio between the encoder and the wheel</li><li>WHEEL_CIRCUMFERENCE - circumference of the wheel in centimetres</li><li>WHEEL_TRACK - distance between the wheels in centimetres</li></ul>
<p>
For the example robot:<p>
<div class="fragment"><pre class="fragment"><span class="preprocessor">  #define ENCODER_TO_WHEEL_RATIO 3</span>
<span class="preprocessor"></span><span class="preprocessor">  #define WHEEL_CIRCUMFERENCE 10.0</span>
<span class="preprocessor"></span><span class="preprocessor">  #define WHEEL_TRACK 20.0</span>
<span class="preprocessor"></span>
<span class="preprocessor">  #include &lt;<a class="code" href="geartrain_8h.html" title="Geartrain calculations and conversions.">lib/geartrain.h</a>&gt;</span>
</pre></div> </div>
</div>
<div class="maincontent">
	<div class="footer centre">
		<hr>
		Generated on Sun Jan 18 22:59:34 2009 by&nbsp;<a href="http://www.doxygen.org/index.html">Doxygen</a> 1.5.6<br/>
		6.270 Staff, 2008 | 
		<a href="mailto:6.270-organizers@mit.edu">Contact Us</a> | 
		<a href="http://web.mit.edu">MIT</a>
	</div>
</div>
</body>
</html>
